package com.rongshu.sendmessage.activity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.rongshu.sendmessage.R;
import com.rongshu.sendmessage.base.BaseActivity;
import com.rongshu.sendmessage.base.MyApplication;
import com.rongshu.sendmessage.util.APKVersionCodeUtils;
import com.rongshu.sendmessage.util.ToastUtils;
import com.rongshu.sendmessage.util.httpUtil.HYContent;
import com.rongshu.sendmessage.util.notifi.NotificationUtil;
import com.rongshu.sendmessage.view.TitileLayout;

public class SettingActivity extends BaseActivity implements View.OnClickListener {

    private Intent mIntent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        mContext=this;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
    }

    private void initView() {
//        TitileLayout tv_title=findViewById(R.id.tv_title);
//        tv_title.setTitle("设置");
//        tv_title.hideRight();
//        tv_title.setTitleClickListener(new TitileLayout.TitleClickListenerA() {
//            @Override
//            public void onLeftClick() {
//                super.onLeftClick();
//                finish();
//            }
//        });
        TextView title=findViewById(R.id.title);
        title.setText("设置");
        findViewById(R.id.titleLayLeft).setOnClickListener(view->finish());

        findViewById(R.id.ll_set_psw).setOnClickListener(this);
        findViewById(R.id.ll_reset_bind_phone).setOnClickListener(this);
        findViewById(R.id.ll_about).setOnClickListener(this);
        findViewById(R.id.btn_login_out).setOnClickListener(this);
        String versionName= APKVersionCodeUtils.getVerName(mContext);
        TextView tv_versionName = findViewById(R.id.tv_versionName);
        tv_versionName.setText("版本："+versionName);
    }

    @Override
    public void onClick(View v) {
        if (v.getId()==R.id.ll_set_psw){
            mIntent=new Intent(mContext, EditPasswordActivity.class);
            startActivity(mIntent);
        }else if(v.getId()==R.id.ll_reset_bind_phone){
            mIntent=new Intent(mContext, ReSetPasswordActivity.class);
            startActivity(mIntent);
        } else if(v.getId()==R.id.btn_login_out){
            mIntent=new Intent(mContext, HYLoginActivity.class);
            mIntent.putExtra("source","user");
            startActivity(mIntent);
            MyApplication.editor.putBoolean(HYContent.IS_LOGIN,false);
            MyApplication.editor.putString(HYContent.USET_TYPE,"");
            MyApplication.editor.commit();
            new NotificationUtil().setTag(mContext,"");
            new NotificationUtil().setAlias(mContext,"");
        }else if(v.getId()==R.id.ll_about){
            //检测版本
            ToastUtils.show(mContext,"已经是最新版本了");
        }
    }
}